//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS DLM service.
///
/// Amazon Data Lifecycle Manager With Amazon Data Lifecycle Manager, you can manage the lifecycle of your Amazon Web Services resources. You create
/// 			lifecycle policies, which are used to automate operations on the specified
/// 			resources. Amazon Data Lifecycle Manager supports Amazon EBS volumes and snapshots. For information about using Amazon Data Lifecycle Manager
/// 			with Amazon EBS, see
/// 				Amazon Data Lifecycle Manager in the Amazon EC2 User Guide.
public struct DLM: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the DLM client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "DLM",
            serviceIdentifier: "dlm",
            serviceProtocol: .restjson,
            apiVersion: "2018-01-12",
            endpoint: endpoint,
            variantEndpoints: Self.variantEndpoints,
            errorType: DLMErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }




    /// FIPS and dualstack endpoints
    static var variantEndpoints: [EndpointVariantType: AWSServiceConfig.EndpointVariant] {[
        [.dualstack]: .init(endpoints: [
            "af-south-1": "dlm.af-south-1.api.aws",
            "ap-east-1": "dlm.ap-east-1.api.aws",
            "ap-northeast-1": "dlm.ap-northeast-1.api.aws",
            "ap-northeast-2": "dlm.ap-northeast-2.api.aws",
            "ap-northeast-3": "dlm.ap-northeast-3.api.aws",
            "ap-south-1": "dlm.ap-south-1.api.aws",
            "ap-south-2": "dlm.ap-south-2.api.aws",
            "ap-southeast-1": "dlm.ap-southeast-1.api.aws",
            "ap-southeast-2": "dlm.ap-southeast-2.api.aws",
            "ap-southeast-3": "dlm.ap-southeast-3.api.aws",
            "ap-southeast-4": "dlm.ap-southeast-4.api.aws",
            "ap-southeast-5": "dlm.ap-southeast-5.api.aws",
            "ap-southeast-7": "dlm.ap-southeast-7.api.aws",
            "ca-central-1": "dlm.ca-central-1.api.aws",
            "ca-west-1": "dlm.ca-west-1.api.aws",
            "cn-north-1": "dlm.cn-north-1.api.amazonwebservices.com.cn",
            "cn-northwest-1": "dlm.cn-northwest-1.api.amazonwebservices.com.cn",
            "eu-central-1": "dlm.eu-central-1.api.aws",
            "eu-central-2": "dlm.eu-central-2.api.aws",
            "eu-north-1": "dlm.eu-north-1.api.aws",
            "eu-south-1": "dlm.eu-south-1.api.aws",
            "eu-south-2": "dlm.eu-south-2.api.aws",
            "eu-west-1": "dlm.eu-west-1.api.aws",
            "eu-west-2": "dlm.eu-west-2.api.aws",
            "eu-west-3": "dlm.eu-west-3.api.aws",
            "il-central-1": "dlm.il-central-1.api.aws",
            "me-central-1": "dlm.me-central-1.api.aws",
            "me-south-1": "dlm.me-south-1.api.aws",
            "mx-central-1": "dlm.mx-central-1.api.aws",
            "sa-east-1": "dlm.sa-east-1.api.aws",
            "us-east-1": "dlm.us-east-1.api.aws",
            "us-east-2": "dlm.us-east-2.api.aws",
            "us-gov-east-1": "dlm.us-gov-east-1.api.aws",
            "us-gov-west-1": "dlm.us-gov-west-1.api.aws",
            "us-west-1": "dlm.us-west-1.api.aws",
            "us-west-2": "dlm.us-west-2.api.aws"
        ]),
        [.dualstack, .fips]: .init(endpoints: [
            "ca-central-1": "dlm-fips.ca-central-1.api.aws",
            "ca-west-1": "dlm-fips.ca-west-1.api.aws",
            "us-east-1": "dlm-fips.us-east-1.api.aws",
            "us-east-2": "dlm-fips.us-east-2.api.aws",
            "us-gov-east-1": "dlm-fips.us-gov-east-1.api.aws",
            "us-gov-west-1": "dlm-fips.us-gov-west-1.api.aws",
            "us-west-1": "dlm-fips.us-west-1.api.aws",
            "us-west-2": "dlm-fips.us-west-2.api.aws"
        ]),
        [.fips]: .init(endpoints: [
            "us-gov-east-1": "dlm.us-gov-east-1.amazonaws.com",
            "us-gov-west-1": "dlm.us-gov-west-1.amazonaws.com"
        ])
    ]}

    // MARK: API Calls

    /// Creates an Amazon Data Lifecycle Manager lifecycle policy. Amazon Data Lifecycle Manager supports the following policy types:   Custom EBS snapshot policy   Custom EBS-backed AMI policy   Cross-account copy event policy   Default policy for EBS snapshots   Default policy for EBS-backed AMIs   For more information, see
    /// 			Default policies vs custom policies.  If you create a default policy, you can specify the request parameters either in
    /// 				the request body, or in the PolicyDetails request structure, but not both.
    @Sendable
    @inlinable
    public func createLifecyclePolicy(_ input: CreateLifecyclePolicyRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateLifecyclePolicyResponse {
        try await self.client.execute(
            operation: "CreateLifecyclePolicy", 
            path: "/policies", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Creates an Amazon Data Lifecycle Manager lifecycle policy. Amazon Data Lifecycle Manager supports the following policy types:   Custom EBS snapshot policy   Custom EBS-backed AMI policy   Cross-account copy event policy   Default policy for EBS snapshots   Default policy for EBS-backed AMIs   For more information, see
    /// 			Default policies vs custom policies.  If you create a default policy, you can specify the request parameters either in
    /// 				the request body, or in the PolicyDetails request structure, but not both.
    ///
    /// Parameters:
    ///   - copyTags:  [Default policies only] Indicates whether the policy should copy tags from the source resource
    ///   - createInterval:  [Default policies only] Specifies how often the policy should run and create snapshots or AMIs.
    ///   - crossRegionCopyTargets:  [Default policies only] Specifies destination Regions for snapshot or AMI copies. You can specify
    ///   - defaultPolicy:  [Default policies only] Specify the type of default policy to create.   To create a default policy for EBS snapshots, that creates snapshots of all volumes in the
    ///   - description: A description of the lifecycle policy. The characters ^[0-9A-Za-z _-]+$ are
    ///   - exclusions:  [Default policies only] Specifies exclusion parameters for volumes or instances for which you
    ///   - executionRoleArn: The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by
    ///   - extendDeletion:  [Default policies only] Defines the snapshot or AMI retention behavior for the policy if the
    ///   - policyDetails: The configuration details of the lifecycle policy.  If you create a default policy, you can specify the request parameters either in
    ///   - retainInterval:  [Default policies only] Specifies how long the policy should retain snapshots or AMIs before
    ///   - state: The activation state of the lifecycle policy after creation.
    ///   - tags: The tags to apply to the lifecycle policy during creation.
    ///   - logger: Logger use during operation
    @inlinable
    public func createLifecyclePolicy(
        copyTags: Bool? = nil,
        createInterval: Int? = nil,
        crossRegionCopyTargets: [CrossRegionCopyTarget]? = nil,
        defaultPolicy: DefaultPolicyTypeValues? = nil,
        description: String? = nil,
        exclusions: Exclusions? = nil,
        executionRoleArn: String? = nil,
        extendDeletion: Bool? = nil,
        policyDetails: PolicyDetails? = nil,
        retainInterval: Int? = nil,
        state: SettablePolicyStateValues? = nil,
        tags: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateLifecyclePolicyResponse {
        let input = CreateLifecyclePolicyRequest(
            copyTags: copyTags, 
            createInterval: createInterval, 
            crossRegionCopyTargets: crossRegionCopyTargets, 
            defaultPolicy: defaultPolicy, 
            description: description, 
            exclusions: exclusions, 
            executionRoleArn: executionRoleArn, 
            extendDeletion: extendDeletion, 
            policyDetails: policyDetails, 
            retainInterval: retainInterval, 
            state: state, 
            tags: tags
        )
        return try await self.createLifecyclePolicy(input, logger: logger)
    }

    /// Deletes the specified lifecycle policy and halts the automated operations that the
    /// 			policy specified. For more information about deleting a policy, see Delete lifecycle
    /// 			policies.
    @Sendable
    @inlinable
    public func deleteLifecyclePolicy(_ input: DeleteLifecyclePolicyRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteLifecyclePolicyResponse {
        try await self.client.execute(
            operation: "DeleteLifecyclePolicy", 
            path: "/policies/{PolicyId}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes the specified lifecycle policy and halts the automated operations that the
    /// 			policy specified. For more information about deleting a policy, see Delete lifecycle
    /// 			policies.
    ///
    /// Parameters:
    ///   - policyId: The identifier of the lifecycle policy.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteLifecyclePolicy(
        policyId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteLifecyclePolicyResponse {
        let input = DeleteLifecyclePolicyRequest(
            policyId: policyId
        )
        return try await self.deleteLifecyclePolicy(input, logger: logger)
    }

    /// Gets summary information about all or the specified data lifecycle policies. To get complete information about a policy, use GetLifecyclePolicy.
    @Sendable
    @inlinable
    public func getLifecyclePolicies(_ input: GetLifecyclePoliciesRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetLifecyclePoliciesResponse {
        try await self.client.execute(
            operation: "GetLifecyclePolicies", 
            path: "/policies", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Gets summary information about all or the specified data lifecycle policies. To get complete information about a policy, use GetLifecyclePolicy.
    ///
    /// Parameters:
    ///   - defaultPolicyType:  [Default policies only] Specifies the type of default policy to get. Specify one of the following:    VOLUME - To get only the default policy for EBS snapshots    INSTANCE - To get only the default policy for EBS-backed AMIs    ALL - To get all default policies
    ///   - policyIds: The identifiers of the data lifecycle policies.
    ///   - resourceTypes: The resource type.
    ///   - state: The activation state.
    ///   - tagsToAdd: The tags to add to objects created by the policy. Tags are strings in the format key=value. These user-defined tags are added in addition to the Amazon Web Services-added lifecycle tags.
    ///   - targetTags: The target tag for a policy. Tags are strings in the format key=value.
    ///   - logger: Logger use during operation
    @inlinable
    public func getLifecyclePolicies(
        defaultPolicyType: DefaultPoliciesTypeValues? = nil,
        policyIds: [String]? = nil,
        resourceTypes: [ResourceTypeValues]? = nil,
        state: GettablePolicyStateValues? = nil,
        tagsToAdd: [String]? = nil,
        targetTags: [String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetLifecyclePoliciesResponse {
        let input = GetLifecyclePoliciesRequest(
            defaultPolicyType: defaultPolicyType, 
            policyIds: policyIds, 
            resourceTypes: resourceTypes, 
            state: state, 
            tagsToAdd: tagsToAdd, 
            targetTags: targetTags
        )
        return try await self.getLifecyclePolicies(input, logger: logger)
    }

    /// Gets detailed information about the specified lifecycle policy.
    @Sendable
    @inlinable
    public func getLifecyclePolicy(_ input: GetLifecyclePolicyRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetLifecyclePolicyResponse {
        try await self.client.execute(
            operation: "GetLifecyclePolicy", 
            path: "/policies/{PolicyId}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Gets detailed information about the specified lifecycle policy.
    ///
    /// Parameters:
    ///   - policyId: The identifier of the lifecycle policy.
    ///   - logger: Logger use during operation
    @inlinable
    public func getLifecyclePolicy(
        policyId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetLifecyclePolicyResponse {
        let input = GetLifecyclePolicyRequest(
            policyId: policyId
        )
        return try await self.getLifecyclePolicy(input, logger: logger)
    }

    /// Lists the tags for the specified resource.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceResponse {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/tags/{ResourceArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Lists the tags for the specified resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceResponse {
        let input = ListTagsForResourceRequest(
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Adds the specified tags to the specified resource.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> TagResourceResponse {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/tags/{ResourceArn}", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds the specified tags to the specified resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource.
    ///   - tags: One or more tags.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        tags: [String: String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> TagResourceResponse {
        let input = TagResourceRequest(
            resourceArn: resourceArn, 
            tags: tags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Removes the specified tags from the specified resource.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UntagResourceResponse {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/tags/{ResourceArn}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Removes the specified tags from the specified resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource.
    ///   - tagKeys: The tag keys.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        tagKeys: [String]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UntagResourceResponse {
        let input = UntagResourceRequest(
            resourceArn: resourceArn, 
            tagKeys: tagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }

    /// Updates the specified lifecycle policy. For more information about updating a policy, see Modify lifecycle
    /// 			policies.
    @Sendable
    @inlinable
    public func updateLifecyclePolicy(_ input: UpdateLifecyclePolicyRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpdateLifecyclePolicyResponse {
        try await self.client.execute(
            operation: "UpdateLifecyclePolicy", 
            path: "/policies/{PolicyId}", 
            httpMethod: .PATCH, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Updates the specified lifecycle policy. For more information about updating a policy, see Modify lifecycle
    /// 			policies.
    ///
    /// Parameters:
    ///   - copyTags:  [Default policies only] Indicates whether the policy should copy tags from the source resource
    ///   - createInterval:  [Default policies only] Specifies how often the policy should run and create snapshots or AMIs.
    ///   - crossRegionCopyTargets:  [Default policies only] Specifies destination Regions for snapshot or AMI copies. You can specify
    ///   - description: A description of the lifecycle policy.
    ///   - exclusions:  [Default policies only] Specifies exclusion parameters for volumes or instances for which you
    ///   - executionRoleArn: The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by
    ///   - extendDeletion:  [Default policies only] Defines the snapshot or AMI retention behavior for the policy if the
    ///   - policyDetails: The configuration of the lifecycle policy. You cannot update the policy type or the
    ///   - policyId: The identifier of the lifecycle policy.
    ///   - retainInterval:  [Default policies only] Specifies how long the policy should retain snapshots or AMIs before
    ///   - state: The desired activation state of the lifecycle policy after creation.
    ///   - logger: Logger use during operation
    @inlinable
    public func updateLifecyclePolicy(
        copyTags: Bool? = nil,
        createInterval: Int? = nil,
        crossRegionCopyTargets: [CrossRegionCopyTarget]? = nil,
        description: String? = nil,
        exclusions: Exclusions? = nil,
        executionRoleArn: String? = nil,
        extendDeletion: Bool? = nil,
        policyDetails: PolicyDetails? = nil,
        policyId: String,
        retainInterval: Int? = nil,
        state: SettablePolicyStateValues? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpdateLifecyclePolicyResponse {
        let input = UpdateLifecyclePolicyRequest(
            copyTags: copyTags, 
            createInterval: createInterval, 
            crossRegionCopyTargets: crossRegionCopyTargets, 
            description: description, 
            exclusions: exclusions, 
            executionRoleArn: executionRoleArn, 
            extendDeletion: extendDeletion, 
            policyDetails: policyDetails, 
            policyId: policyId, 
            retainInterval: retainInterval, 
            state: state
        )
        return try await self.updateLifecyclePolicy(input, logger: logger)
    }
}

extension DLM {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: DLM, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
